home *** CD-ROM | disk | FTP | other *** search
Text File | 1991-02-07 | 5.1 KB | 160 lines | [TEXT/MPS ] |
- {-------------------------------------------------------------------------------
- #
- # Apple Macintosh Developer Technical Support
- #
- # Code for process-list LDEF
- #
- # Program: ProcDoggie
- # File: UProcessLDEF.inc1.p - Pascal Implementation
- #
- # by: Forrest Tanaka
- #
- # Copyright © 1988-1991 Apple Computer, Inc.
- # All rights reserved.
- #
- -------------------------------------------------------------------------------}
- {[j=20/57/1$] Pasmat Options}
- {$R-}
-
-
- CONST
- kCellMargin = 3; {Margin between list contents and list edge in pixels}
-
-
- PROCEDURE DrawCell (cellRect: Rect; theCell: Cell; selected: Boolean;
- theList: ListHandle; dataOffset: Integer);
- FORWARD;
- PROCEDURE HilightCell (cellRect: Rect);
- FORWARD;
-
-
- {$S Main}
- (*******************************************************************************
- * Public: ProcessList
- *
- * Here’s the entry point to my custom LDEF. Yup.
- *******************************************************************************)
-
- PROCEDURE ProcessList (message: Integer;
- selectCell: Boolean;
- cellRect: Rect;
- theCell: Cell;
- dataOffset: Integer;
- dataLength: Integer;
- theList: ListHandle);
-
- BEGIN
- IF message = lDrawMsg THEN
- BEGIN
- IF dataLength > 0 THEN
- DrawCell (cellRect, theCell, selectCell, theList, dataOffset)
- END
- ELSE IF message = lHiliteMsg THEN
- HilightCell (cellRect)
- END;
-
-
- {$S Main}
- (*******************************************************************************
- * Private: DrawCell - Draw the contents of the specified cell
- *
- * This routine draws the contents of the cell specified by theCell into it’s
- * rectangle, which is specified by cellRect. In case the font is too large for
- * the cell rectangle, I set the clip region to cellRect before drawing the cell
- * text, then set it back to what it was afterwards.
- *
- * If selected is TRUE, then theCell is selected. In that case, my HilightCell
- * routine is called to hilight the cell.
- *
- * The list that this all takes place in is specified by theList.
- *******************************************************************************)
-
- PROCEDURE DrawCell (cellRect: Rect;
- theCell: Cell;
- selected: Boolean;
- theList: ListHandle;
- dataOffset: Integer);
-
- VAR
- cellInfo: ProcessListInfoRec; {Information for cell to be drawn}
- currClip: RgnHandle; {Handle to the current clip region}
- currPen: PenState; {Current pen characteristics}
- currFont: FontInfo; {Current font characteristics}
- dataLen: Integer; {Length of cell data in bytes}
- marginRect: Rect; {Rect that process name is drawn into}
- alignment: Integer; {Alignment of process name text}
- spareSpace: Integer; {marginRect width - text width}
-
- BEGIN
- (* Save the current pen state and set the default pen characteristics *)
- GetPenState ((*<*)currPen);
- PenNormal;
-
- (* Save the current clip region and set it to cellRect *)
- currClip := NewRgn;
- GetClip ((*<*)currClip);
- ClipRect (cellRect);
-
- (* Will draw text into the cell rect with a margin on left and right *)
- marginRect := cellRect;
- InsetRect ((*◊*)marginRect, kCellMargin, 0);
-
- (* Get the information for the specified cell *)
- dataLen := SIZEOF (ProcessListInfoRec);
- LGetCell ((*<*)Ptr(@cellInfo), (*◊*)dataLen, theCell, theList);
-
- (* To find where to draw the cell’s text, get current font information *)
- GetFontInfo ((*<*)currFont);
-
- (* Position the pen for drawing the text *)
- MoveTo (marginRect.left, marginRect.top + currFont.ascent);
-
- (* Determine whether system script is left-to-right or right-to-left *)
- IF GetSysJust = 0 THEN
- alignment := teFlushLeft
- ELSE
- alignment := teFlushRight;
-
- (* Adjust the pen for right-aligned text if script is right-to-left *)
- IF alignment = teFlushRight THEN
- BEGIN
- spareSpace := marginRect.right - marginRect.left -
- StringWidth (cellInfo.processName);
- Move (spareSpace, 0);
- END;
-
- (* Draw the cell’s contents *)
- EraseRect (cellRect);
- DrawString (cellInfo.processName);
-
- (* If the cell is selected, hilight it *)
- IF selected THEN
- HilightCell (cellRect);
-
- (* Restore the current clip region and pen *)
- SetClip (currClip);
- DisposeRgn (currClip);
- SetPenState (currPen);
- END;
-
-
- {$S Main}
- (*******************************************************************************
- * Private: HilightCell - Hilight the specified cell
- *
- * This routine hilights the cell whose rectangle is cellRect. I also clear the
- * hilight bit of the HiliteMode low-memory global. If this is running on a
- * Color QuickDraw machine, then background hilighting is done instead of
- * the usual inversion.
- *******************************************************************************)
-
- PROCEDURE HilightCell (cellRect: Rect);
-
- BEGIN
- (* Do the fancy, new kind of hilighting on a Color QuickDraw Mac *)
- BitClr (Ptr(HiliteMode), pHiliteBit);
-
- (* Now, hilight the cell *)
- InvertRect (cellRect)
- END;
-